package com.atguigu.yygh.hosp.service.impl;

import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.model.hosp.HospitalSet;
import com.atguigu.yygh.hosp.mapper.HospitalSetMapper;
import com.atguigu.yygh.hosp.service.HospitalSetService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>MybatisPlus自动生成
 * 医院设置表 服务实现类
 * </p>
 *
 * @author atguigu
 * @since 2021-08-26
 */
@Service
public class HospitalSetServiceImpl extends ServiceImpl<HospitalSetMapper, HospitalSet> implements HospitalSetService {



    /*
    这个就不需要要了 因为MybatisPlus封装到了ServiceImpl里,只要继承ServiceImpl就可实现对HospitalSetMapper的调用
    @Autowired
    private HospitalSetMapper hospitalSetMapper;*/

    //根据医院编号查询
    @Override
    public String getSignkey(String hoscode) {
        //根据传递过来的hoscode查询本地数据中的hospitalSet信息
        HospitalSet hospitalSet =  this.getHospitalSetByHoscode(hoscode);
        //获取hospitalSet中的hoscode1
        String hoscode1 = hospitalSet.getSignKey();
        return hoscode1;
    }
    //根据医院编号(hoscode)查询HospitalSet 医院设置信息
    private HospitalSet getHospitalSetByHoscode(String hoscode) {
        //条件查询 根据hoscode查询一条HospitalSet记路
        HospitalSet hospitalSet = baseMapper.selectOne(new QueryWrapper<HospitalSet>().eq("hoscode", hoscode));
        return hospitalSet;
    }

}
